package com.zhangc.blog.admin.service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangc.blog.admin.entity.BlogConfigEntity;
import com.zhangc.blog.admin.mapper.BlogConfigMapper;

@Service
public class BlogConfigServiceImpl extends ServiceImpl<BlogConfigMapper, BlogConfigEntity> {

    @Autowired
    private BlogConfigMapper blogConfigMapper;

    public Map<String, String> getAllConfigs() {
        List<BlogConfigEntity> list = blogConfigMapper.selectList(null);
        return list.stream().collect(Collectors.toMap(
                BlogConfigEntity::getConfigField, BlogConfigEntity::getConfigValue
        ));
    }
}
